﻿using System;
using hr_1.Model;

namespace hr_1.ViewModel
{
    public class PersonViewModel: ViewModelBase
    {
        #region Fields

        readonly Person _person = new Person();

        #endregion // Fields

        #region Constructor

        public PersonViewModel() { }

        public PersonViewModel(Person person)
        {
            if (person == null)
                throw new ArgumentNullException("person");

            _person = person;
        }

        #endregion // Constructor

        #region Person Properties

        public int PersonId
        {
            get { return _person.PersonId; }
        }

        public int PersonalDocId
        {
            get { return _person.PersonalDocId; }
            set { _person.PersonalDocId = value; }
        }

        public int PersonalInfoId
        {
            get { return _person.PersonalInfoId; }
            set { _person.PersonalInfoId = value; }
        }

        public int WorkActivityId
        {
            get { return _person.WorkActivityId; }
            set { _person.WorkActivityId = value; }
        }

        public string Firstname
        {
            get { return _person.Firstname; }
            set
            {
                if (value == _person.Firstname)
                    return;
                _person.Firstname = value;
                base.OnPropertyChanged("Firstname");
            }
        }

        public string Middlename
        {
            get { return _person.Middlename; }
            set
            {
                if (value == _person.Middlename)
                    return;
                _person.Middlename = value;
                base.OnPropertyChanged("Middlename");
            }
        }

        public string Lastname
        {
            get { return _person.Lastname; }
            set
            {
                if (value == _person.Lastname)
                    return;
                _person.Lastname = value;
                base.OnPropertyChanged("Lastname");
            }
        }

        public string Birthday
        {
            get { return _person.Birthday; }
            set
            {
                if (value == _person.Birthday)
                    return;
                _person.Birthday = value;
                base.OnPropertyChanged("Birthday");
            }
        }

        public string Sex
        {
            get { return _person.Sex; }
            set
            {
                if (value == _person.Sex)
                    return;
                _person.Sex = value;
                base.OnPropertyChanged("Sex");
            }
        }

        public string DateBeginWork
        {
            get { return _person.Date_begin_work; }
            set
            {
                if (value == _person.Date_begin_work)
                    return;
                _person.Date_begin_work = value;
                base.OnPropertyChanged("DateBeginWork");
            }
        }
        #endregion // Person Properties

        #region Public Methods

        public void Save()
        {
            _person.Save();
        }

        #endregion // Public Methods
    }

}
